#include "sbox.h"
#include "ui_sbox.h"


SBox::SBox(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::SBox)
{
    this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint);
    ui->setupUi(this);
    QWebEngineView *view = new QWebEngineView(this);
    QWebEnginePage *page = new QWebEnginePage(this);
    view->setPage(page);
    QWebChannel *channel = new QWebChannel(this);
    view->page()->setWebChannel(channel);
    channel->registerObject(QStringLiteral("webchannel"), &wc);
    ui->stackedWidget->insertWidget(0, view);
    view->load(QUrl(QApplication::applicationDirPath() + "/html/login.html"));
    ui->stackedWidget->setCurrentIndex(0);

    connect(&wc,SIGNAL(loginFinished()),ui->stackedWidget,SLOT(next()));

}

SBox::~SBox()
{
    delete ui;
}

void SBox::next()
{
    int current = ui->stackedWidget->currentIndex();
    ui->stackedWidget->setCurrentIndex(current + 1);
}

void SBox::forward()
{
    int current = ui->stackedWidget->currentIndex();
    ui->stackedWidget->setCurrentIndex(current - 1);
}



